package com.rainbow.bam.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.rainbow.bam.properties.ServiceProperties;

/**
 * 访问请求拦截器
 * 
 * @author HarrisonHan
 * @version $Id: SiteHandlerInterceptor.java, v 0.1 2015年10月29日 下午6:17:07 HarrisonHan Exp $
 */
public class SiteHandlerInterceptor extends HandlerInterceptorAdapter {

    /**
     * 资源properties
     */
    private ServiceProperties serviceProperties;

    public void postHandle(HttpServletRequest request, HttpServletResponse response,
                           Object handler, ModelAndView modelAndView) throws Exception {
        request.setAttribute("cdn", serviceProperties.getCdn());
        request.setAttribute("domain", serviceProperties.getDomain());
        request.setAttribute("systemFirstName", serviceProperties.getFirstName());
        request.setAttribute("systemSecondName", serviceProperties.getSecondName());
        request.setAttribute("systemGroup", serviceProperties.getGroup());
    }

    public ServiceProperties getServiceProperties() {
        return serviceProperties;
    }

    public void setServiceProperties(ServiceProperties serviceProperties) {
        this.serviceProperties = serviceProperties;
    }
}
